const { successData, sendCode } = require("@/utils/r/result");
const resourceService = require("@/server/resource");

const resource = {
  //获取资源列表
  async GetTreeList(req, res) {
    const query = req.query || {};
    successData(res, await resourceService.GetTreeList(query));
  },
  async UpdateAnonymous(req, res) {
    sendCode(res, await resourceService.UpdateAnonymous(req.body));
  },
  async SaveOrUpdate(req, res) {
    sendCode(res, await resourceService.SaveOrUpdate(req.body));
  },
  async Delete(req, res) {
    let id = req.params?.id;
    sendCode(res, await resourceService.Delete(id));
  },
  // 角色管理模块界面选择树形数据
  async GetOption(req, res) {
    successData(res, await resourceService.GetOptionList());
  },
};

module.exports = resource;
